export default {
	/**
	 * 通用方法-带认证
	 */
	authenticatorList: async (host, token, data) => {
		try {
			let response = await uni.request({
				url: host,
				method: 'GET',
				header: {
					'content-type': 'application/json',
					'authorization': token
				},
				data: data
			})
			return response.data;
		} catch (e) {
			throw e;
		}
	},
	authenticatorRead: async (host, token) => {
		try {
			let response = await uni.request({
				url: host,
				method: 'GET',
				header: {
					'content-type': 'application/json',
					'authorization': token
				}
			})
			return response.data;
		} catch (e) {
			throw e;
		}
	},
	authenticatorPost: async (host, token, data) => {
		try {
			let response = await uni.request({
				url: host,
				method: 'POST',
				header: {
					'content-type': 'application/json',
					'authorization': token
				},
				data: data
			})
			return response.data;
		} catch (e) {
			throw e;
		}
	},
	authenticatorPatch: async (host, token, data) => {
		try {
			let response = await uni.request({
				url: host,
				method: 'PATCH',
				header: {
					'content-type': 'application/json',
					'authorization': token
				},
				data: data
			})
			return response.data;
		} catch (e) {
			throw e;
		}
	},
	authenticatorDelete: async (host, token) => {
		try {
			let response = await uni.request({
				url: host,
				method: 'DELETE',
				header: {
					'content-type': 'application/json',
					'authorization': token
				}
			})
			return response.data;
		} catch (e) {
			throw e;
		}
	},
	/**
	 * 请求COS上传密钥
	 */
	getCosToken: async (host, token) => {
		try {
			let response = await uni.request({
				url: host + '/api/cosSt/',
				method: 'POST',
				header: {
					'content-type': 'application/json',
					'authorization': token
				},
				data: {}
			})
			return response.data;
		} catch (e) {
			throw e;
		}
	},
	/**
	 * 后台权限列表
	 */
	adminAuthViewList: async (host, token, pk) => {
		try {
			let response = await uni.request({
				url: pk ? host + '/api/allview/' + pk + '/' : host + '/api/allview/',
				method: 'GET',
				header: {
					'content-type': 'application/json',
					'authorization': token
				}
			})
			return response.data;
		} catch (e) {
			throw e;
		}
	},
	/**
	 * 配置管理员权限
	 */
	adminPermsViewPost: async (host, token, data) => {
		try {
			let response = await uni.request({
				url: host + '/api/parmAdmin/',
				method: 'POST',
				header: {
					'content-type': 'application/json',
					'authorization': token
				},
				data: data
			})
			return response.data;
		} catch (e) {
			throw e;
		}
	},
	/**
	 * 管理员登录
	 * @param {*} host 
	 * @param {*} data 
	 */
	adminLogin: async (host, data) => {
		try {
			let response = await uni.request({
				url: host + '/admin/login/',
				method: 'POST',
				header: {
					'content-type': 'application/json'
					// 'authorization': token
				},
				data: data
			})
			return response.data;
		} catch (e) {
			throw e;
		}
	},
	/**
	 * 用户信息
	 */
	adminGetStaffList: async (host, token, data) => {
		try {
			let response = await uni.request({
				url: host + '/admin/staff/',
				method: 'GET',
				header: {
					'content-type': 'application/json',
					'authorization': token
				},
				data: data
			})
			return response.data;
		} catch (e) {
			throw e;
		}
	},
	/**
	 * patch用户状态
	 */
	adminPatchStaffList: async (host, token, data, pk) => {
		try {
			let response = await uni.request({
				url: host + '/admin/staff/' + pk + '/',
				method: 'PATCH',
				header: {
					'content-type': 'application/json',
					'authorization': token
				},
				data: data
			})
			return response.data;
		} catch (e) {
			throw e;
		}
	},
	/**
	 * 管理员列表
	 */
	adminGetAdminList: async (host, token, data) => {
		try {
			let response = await uni.request({
				url: host + '/admin/admin/',
				method: 'GET',
				header: {
					'content-type': 'application/json',
					'authorization': token
				},
				data: data
			})
			return response.data;
		} catch (e) {
			throw e;
		}
	},
	/**
	 * patch管理员状态
	 */
	adminPatchAdminList: async (host, token, data, pk) => {
		try {
			let response = await uni.request({
				url: host + '/admin/admin/' + pk + '/',
				method: 'PATCH',
				header: {
					'content-type': 'application/json',
					'authorization': token
				},
				data: data
			})
			return response.data;
		} catch (e) {
			throw e;
		}
	},
	/**
	 * 商品分类
	 */
	adminGoodsModeList: async (host, token, data) => {
		try {
			let response = await uni.request({
				url: host + '/admin/goodsMode/',
				method: 'GET',
				header: {
					'content-type': 'application/json',
					'authorization': token
				},
				data: data
			})
			return response.data;
		} catch (e) {
			throw e;
		}
	},
	/**
	 * 商品信息
	 */
	adminGoodsProductList: async (host, token, data) => {
		try {
			let response = await uni.request({
				url: host + '/admin/goodsProt/',
				method: 'GET',
				header: {
					'content-type': 'application/json',
					'authorization': token
				},
				data: data
			})
			return response.data;
		} catch (e) {
			throw e;
		}
	},
	/**
	 * 创建商品
	 */
	adminGoodsProductPost: async (host, token, data) => {
		try {
			let response = await uni.request({
				url: host + '/admin/goodsProt/',
				method: 'POST',
				header: {
					'content-type': 'application/json',
					'authorization': token
				},
				data: data
			})
			return response.data;
		} catch (e) {
			throw e;
		}
	}
}